mui.init({
    pullRefresh: {
        container: '#pullrefresh',
        down: {
            style:'circle',
            callback: pulldownRefresh
        },
        up: {
            auto:true,
            contentrefresh: '正在加载...',
            callback: pullupRefresh
        }
    }
});

var count = 0;
function pullupRefresh() {
    setTimeout(function() {
        mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
        var table = document.body.querySelector('.mui-table-view');
        var cells = document.body.querySelectorAll('.mui-table-view-cell');
        var newCount = cells.length>0?5:20;//首次加载20条，满屏
        for (var i = cells.length, len = i + newCount; i < len; i++) {
            var li = document.createElement('li');
            li.className = 'pull__li';
            // li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
            li.innerHTML =
                '<h5 class="pull__li__time mui-text-center">2018-12-12 21:11-08</h5>' +
                '<h5 class="pull__li__tit">支付宝收款</h5>' +
                '<p>2018-11-21 14:07:13</p>' +
                '<p>终端号：61247450</p>' +
                '<p>商户名称：上海来伊份金科路店</p>' +
                '<p>交易单号：R201811211407130374500251</p>' +
                '<p>收单来源：微信支付-上海银行信用卡(5908)</p>' +
                '<p>收款金额：598.58 元</p>' +
                '<p class="pull__li__detail">详情  ></p>';
            table.appendChild(li);
            bindClick(li);
        }
    }, 1000);
}

function addData() {
    var table = document.body.querySelector('.mui-table-view');
    var cells = document.body.querySelectorAll('.mui-table-view-cell');
    for(var i = cells.length, len = i + 5; i < len; i++) {
        var li = document.createElement('li');
        li.className = 'mui-table-view-cell';
        li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
        //下拉刷新，新纪录插到最前面；
        table.insertBefore(li, table.firstChild);
        bindClick(li);
    }
}
/**
 * 下拉刷新具体业务实现
 */
function pulldownRefresh() {
    setTimeout(function() {
        addData();
        mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
        mui.toast("为你推荐了5篇文章");
    }, 1000);
}

function bindClick(ele) {
    ele.addEventListener('tap',function () {
        // alert(1)
        // mui("#pullrefresh")[0].style.display = 'none';
        // mui("#detail")[0].style.display = 'block';
    })
}